﻿
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>生产工艺库</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
     <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script type="text/html" id="barDemo">
        <a title="编辑" href="javascript:;" lay-event="update" id="frmEdit"><i class="layui-icon">&#xe642;</i></a>
        <a title="删除" href="javascript:;" lay-event="del" id="frmDel"><i class="layui-icon">&#xe640;</i></a>

    </script>

</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="versionCode" placeholder="工艺版本" class="layui-input" id="versionCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="relationCode" placeholder="关联编码" class="layui-input" id="relationCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="relationName" placeholder="关联名称" class="layui-input" id="relationName">
                            </div>

                        </form>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var currPage = 1;//首先默认值为1，防止出错
    var dUrl = "../ProductSet/getDataList?dataType=gsp&condition=";
    /**
    数据加载
    **/
    function loadData() {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                    { field: 'keyCode', title: '工艺编码', width: 150 }
                    , { field: 'gyName', title: '工艺名称', width: 180 }
                    , { field: 'relationName', title: '关联数据', width: 250 }
                    , { field: 'versionCode', title: '工艺版本', width: 100 }
                    , { field: 'memo', title: '备注说明', width: 130 }
                    , { field: 'right', title: '数据操作', toolbar: '#barDemo', width: 100, fixed: 'right' }
                ]], done: function (res, curr, count) {
                    currPage = curr;
                    TablePowerHide();
                }
                , url: dUrl + conditon
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 20, 30]
                , limit: 15 //每页默认显示的数量
                , id: "tData"
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        var info = DelData(data.keyCode,data.gxCode,data.relationCode);
                        if (info.result) {
                            obj.del();
                        } else {
                            layer.msg(info.message);
                        }
                        layer.close(index);
                    });
                } else if (obj.event == 'update') {
                    var title = "工艺修改-" + data.relationName;
                    var conditon = JSON.stringify(FormToJson("qForm"));
                    let url = "../ProductSet/ProductProcessForm?keyCode=" + data.keyCode + "&memo=" + data.memo +
                        "&reCode=" + data.relationCode +"&version="+data.versionCode+"&gyName="+data.gyName;
                    NewOpenPage(url, title, "80%", "90%", "tData", currPage, dUrl + conditon);
                }
            });

        });
    }
    var menuCode = "";
    $(function () {
        menuCode = getUrlVariable("menuCode");
        BannerData(menuCode, "bDiv");
        loadData();
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                loadData();
            }
        })
    })

    function openWin() {
        InfoOpenPage("../ProductSet/ProductProcessForm?keyCode=&reCode=", "工艺配置", "85%", "90%");
    }
    /**
    删除方法
    **/
    function DelData(keyCode, gxCode, relaitionCode) {
        var info = undefined;
        $.ajax({          
            url: "../ProductSet/DelGyStandard",
            data: { keyCode: keyCode, gxCode: gxCode ,relationCode:relaitionCode},
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                info = data;
            }
        });
        return info;
    }

</script>